<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="renderer" content="webkit|ie-comp|ie-stand" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="../assets/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="../css/style.css" />
<link href="../assets/css/codemirror.css" rel="stylesheet" />
<link rel="stylesheet" href="../assets/css/ace.min.css" />
<link rel="stylesheet" href="../font/css/font-awesome.min.css" />
<script src="../js/jquery-1.9.1.min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../Widget/Validform/5.3.2/Validform.min.js"></script>
<script src="../assets/js/typeahead-bs2.min.js"></script>
<script src="../assets/js/jquery.dataTables.min.js"></script>
<script src="../assets/js/jquery.dataTables.bootstrap.js"></script>
<script src="../assets/layer/layer.js" type="text/javascript"></script>
<script src="../js/lrtk.js" type="text/javascript"></script>
<script src="../assets/layer/layer.js" type="text/javascript"></script>
<script src="../assets/laydate/laydate.js" type="text/javascript"></script>
<script type="text/javascript">
	/* 鼠标特效 */
	var a_idx = 0;
	jQuery(document).ready(function($) {
		$("body").click(function(e) {
		 var a = new Array( "富强", "民主","文明", "和谐", "自由", "平等","公正", "法治", "爱国", "敬业","诚信", "友善");
		 var $i = $("<span/>").text(a[a_idx]);a_idx = (a_idx + 1) % a.length;
		 var x = e.pageX, y = e.pageY;
			 $i.css({
					 "z-index" : 999999999999999999999999999999999999999999999999999999999999999999999,
					 "top" : y - 20,
					 "left" : x,
					 "position" : "absolute",
					 "font-weight" : "bold",
					 "color" : "#6840bf"
					});
					 $("body").append($i);
					 $i.animate({
						"top" : y - 180,
						"opacity" : 0
						}, 1500, function() {
						 $i.remove();
				  });
		});
	};
</script>

<script>
        function(){
            location.href="${request.pageContext.contextPath}/tfood/ht/cylogin";
        };
    </script>
<title>管理员</title>
</head>

<body>



	<div class="cover_style" id="cover_style" style="margin-left: 100px">

		<!--内容-->
		<div>
			<div>

				<!--左侧样式-->
				<div>


					<div class="border clearfix">
						<span class="l_f"> <a href="javascript:ovid()"
							onclick="administrator_add()" id="administrator_add"
							class="btn btn-warning"><img src="../images/add.png"
								style="width: 15px; height: 15px"></img> 添加管理员</a>
						</span>

					</div>

					<!--订单列表展示-->
					<table class="table table-striped table-bordered table-hover"
						id="sample-table" style="margin-left: 0px">
						<thead>
							<tr>
								<th width="80px">编号</th>
								<th width="100px">登录名</th>
								<th width="200px">密码</th>
								<th width="80px">性别</th>
								<th width="80px">年龄</th>
								<th width="100px">手机</th>
								<th width="150px">邮箱</th>

								<th width="200px">操作</th>

							</tr>
						</thead>
						<tbody>
							<c:forEach items="${userlist }" var="user">
								<tr>
									<td>${user.id}</td>
									<td>${user.user_name}</td>
									<td>${user.user_password}</td>
									<td><c:if test="${user.user_gender==0}">
                            		女
                            </c:if> <c:if test="${user.user_gender==1}">
                            		男
                            </c:if></td>
									<td>${user.user_age}</td>
									<td>${user.user_tel}</td>
									<td>${user.user_email}</td>

									<td class="td-manage"><a title="编辑"
										onclick="member_update(this,${user.id});"
										class="btn btn-xs btn-info"><img
											src="../images/update.png" style="width: 15px; height: 15px"></img></a>
										<a title="删除" href="javascript:;"
										onclick="member_del(this,${user.id})"
										class="btn btn-xs btn-warning"><img
											src="../images/delete.png" style="width: 15px; height: 15px"></img></a>


									</td>



								</tr>
							</c:forEach>
						</tbody>
					</table>
				</div>
			</div>
		</div>

	</div>
	<!--发货-->
	<div id="add_administrator_style" class="add_menber"
		style="display: none">
		<form action="../huser/adduser" method="post"
			id="form-admin-add">
			<div class="form-group">
				<label class="form-label"><span class="c-red">*</span>管理员：</label>
				<div class="formControls">
					<input type="text" class="input-text" value="" placeholder="请输入名称"
						id="user-name" name="name" datatype="*2-16" nullmsg="用户名不能为空" />
				</div>
				<div class="col-4">
					<span class="Validform_checktip"></span>
				</div>
			</div>
			<div class="form-group">
				<label class="form-label"><span class="c-red">*</span>密码：</label>
				<div class="formControls">
					<input type="password" placeholder="密码" name="password"
						autocomplete="off" value="" class="input-text" datatype="*6-20"
						nullmsg="密码不能为空" />
				</div>
				<div class="col-4">
					<span class="Validform_checktip"></span>
				</div>
			</div>
			<div class="form-group">
				<label class="form-label "><span class="c-red">*</span>性别：</label> <select
					class="select" name="sex">
					<option value="1">男</option>
					<option value="0">女</option>

				</select>
				<div class="col-4">
					<span class="Validform_checktip"></span>
				</div>
			</div>
			<div class="form-group">
				<label class="form-label"><span class="c-red">*</span>年龄：</label>
				<div class="formControls">
					<input type="text" placeholder="年龄" name="age" autocomplete="off"
						value="" class="input-text" datatype="*0-2" nullmsg="年龄不能为空" />
				</div>
				<div class="col-4">
					<span class="Validform_checktip"></span>
				</div>
			</div>
			<div class="form-group">
				<label class="form-label "><span class="c-red">*</span>手机：</label>
				<div class="formControls ">
					<input type="text" class="input-text" value=""
						placeholder="请输入手机号码" id="user-tel" name="tel" datatype="m"
						nullmsg="手机不能为空" />
				</div>
				<div class="col-4">
					<span class="Validform_checktip"></span>
				</div>
			</div>
			<div class="form-group">
				<label class="form-label"><span class="c-red">*</span>邮箱：</label>
				<div class="formControls ">
					<input type="text" class="input-text" placeholder="@" name="email"
						id="email" datatype="e" nullmsg="请输入邮箱！" />
				</div>
				<div class="col-4">
					<span class="Validform_checktip"></span>
				</div>
			</div>


			<input class="btn btn-primary radius" type="submit"
				id="Add_Administrator" value="&nbsp;&nbsp;提交&nbsp;&nbsp;" />
		</form>
	</div>
	</div>
</body>
</html>
<script type="text/javascript">
    $(function() {
        var oTable1 = $('#sample-table').dataTable( {
            "aaSorting": [],//默认第几个排序
            "bStateSave": false,//状态保存
            //"dom": 't',
            "bFilter":false,
            "aoColumnDefs": [
                //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                {"orderable":false,"aTargets":[0,1,2,3,4]}// 制定列不参与排序
            ] } );
        $('table th input:checkbox').on('click' , function(){
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function(){
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });

        });
    })

</script>
<script type="text/javascript">
    $(function() {
        $("#administrator").fix({
            float : 'left',
            //minStatue : true,
            skin : 'green',
            durationTime :false,
            spacingw:50,//设置隐藏时的距离
            spacingh:270,//设置显示时间距
        });
    });
    //字数限制
    function checkLength(which) {
        var maxChars = 100; //
        if(which.value.length > maxChars){
            layer.open({
                icon:2,
                title:'提示框',
                content:'您输入的字数超过限制!',
            });
            // 超过限制的字数了就将 文本框中的内容按规定的字数 截取
            which.value = which.value.substring(0,maxChars);
            return false;
        }else{
            var curr = maxChars - which.value.length; //250 减去 当前输入的
            document.getElementById("sy").innerHTML = curr.toString();
            return true;
        }
    };
    //初始化宽度、高度
    $(".widget-box").height($(window).height()-215);
    $(".table_menu_list").width($(window).width()-260);
    $(".table_menu_list").height($(window).height()-215);
    //当文档窗口发生改变时 触发
    $(window).resize(function(){
        $(".widget-box").height($(window).height()-215);
        $(".table_menu_list").width($(window).width()-260);
        $(".table_menu_list").height($(window).height()-215);
    })
    laydate({
        elem: '#start',
        event: 'focus'
    });

    /*用户-停用*/
    function member_stop(obj,id){
        layer.confirm('确认要停用吗？',function(index){
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs " onClick="member_start(this,id)" href="javascript:;" title="启用"><i class="fa fa-close bigger-120"></i></a>');
            $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已停用</span>');
            $(obj).remove();
            layer.msg('已停用!',{icon: 5,time:1000});
        });
    }
    /*用户-启用*/
    function member_start(obj,id){
        layer.confirm('确认要启用吗？',function(index){
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs btn-success" onClick="member_stop(this,id)" href="javascript:;" title="停用"><i class="fa fa-check  bigger-120"></i></a>');
            $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
            $(obj).remove();
            layer.msg('已启用!',{icon: 6,time:1000});
        });
    }

    function member_update(obj,id) {
        window.location.href='../huser/viewuserdetaile?id='+id;

    }
    /*产品-编辑*/
    function member_edit(title,url,id,w,h){
        layer_show(title,url,w,h);

    }

    /*产品-删除*/
    function member_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $(obj).parents("tr").remove();

            layer.msg('已删除!',{icon:1,time:1000});


            $.ajax({
                type:"GET",
                url:"${pageContext.request.contextPath}/huser/deleteuser?id="+id,
                dataType:"json",
                success:function(data){
                    if(data.success){
                        $("searchResult").html(data.msg);

                    }else{
                        $("#searchResult").html("出现错误：" + data.msg);
                    }
                },
                error:function(jqXHR){
                    aler("发生错误："+ jqXHR.status);
                }
            });


        });
    }
    /*添加管理员*/
    function administrator_add(){


        layer.open({
            type: 1,
            title:'添加管理员',
            area: ['700px',''],
            shadeClose: false,
            content: $('#add_administrator_style'),

        });
    }
    //表单验证提交
    $("#form-admin-add").Validform({

        tiptype:2,

        callback:function(data){
            //form[0].submit();
            if(data.status==1){
                layer.msg(data.info, {icon: data.status,time: 1000}, function(){
                    location.reload();//刷新页面
                });
            }
            else{
                layer.msg(data.info, {icon: data.status,time: 3000});
            }
            var index =parent.$("#iframe").attr("src");
            parent.layer.close(index);
            //
        }


    });
</script>

